package day11.fanxingdemo;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.util.ArrayList;

public class fanxingdemo1 {
   public static void main(String[] args) {
      ArrayList list = new ArrayList();
      list.add(1);
      list.add("hello");
      list.add(true);
      list.remove(1);
      System.out.println(list);

   }

}
//学生类和老师类的增删改查方法
@lombok.Data
@NoArgsConstructor
@AllArgsConstructor
class Student implements Data<Student>
{
int age;
//private static ArrayList <Student>list = new ArrayList<>();

    //方法只是为了语法，没法和age挂钩
    @Override
    public void add(Student student) {

    }

    @Override
    public void remove(Student student) {

    }

    @Override
    public void update(Student student) {

    }

    @Override
    public Student find(int id) {
        return null;
    }
}

@lombok.Data
@NoArgsConstructor
@AllArgsConstructor
class Teacher implements Data<Teacher>
{
 int age;

    @Override
    public void add(Teacher teacher) {

    }

    @Override
    public void remove(Teacher teacher) {

    }

    @Override
    public void update(Teacher teacher) {

    }

    @Override
    public Teacher find(int id) {
        return null;
    }
}
interface Data<T>     //泛型接口，泛型就是广泛的类型可以看成他能接很多个类型，这个T就是接了学生那就是只对学生进行操作
                          //如果实现类没有<具体化类型>就是没有用到泛型就是默认T=Object了
 {
       void add(T t);
       void remove(T t);
       void update(T t);
       T find(int id);
 }

